package com.example.menu_activitys;

import android.R.drawable;
import android.content.res.Resources;
import android.os.Bundle;
import android.app.ActionBar.LayoutParams;
import android.app.AlertDialog.Builder;
import android.app.Activity;
import android.app.ActivityGroup;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends ActivityGroup {

	private Typeface actionFont;
	TextView titulo;
	ImageView info;
	Button bInfo;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		setContentView(R.layout.activity_main);

		// Lanzar empezar
		String infService = Context.LAYOUT_INFLATER_SERVICE;
		LayoutInflater li = (LayoutInflater) getApplicationContext()
				.getSystemService(infService);
		View inflador = li.inflate(R.layout.empezar, null);
		Builder ventana = new AlertDialog.Builder(this);
		ventana.setView(inflador);		
		ventana.show();

		// Fuente titulo
		titulo = (TextView) findViewById(R.id.textView1);
		actionFont = Typeface.createFromAsset(getAssets(), "fonts/actionj.ttf");
		titulo.setTypeface(actionFont);

		// Cargar imagen
		info = (ImageView) findViewById(R.id.imageView1);
		info.setBackgroundResource(android.R.drawable.ic_menu_info_details);

		// Lanzar informacion
		bInfo = (Button) findViewById(R.id.button2);

		bInfo.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {

				// lanzamos INFORMACION
				String infService2 = Context.LAYOUT_INFLATER_SERVICE;
				LayoutInflater li2 = (LayoutInflater) getApplicationContext()
						.getSystemService(infService2);
				View inflador2 = li2.inflate(
						R.layout.activity_informacion, null);
				Builder ventana2 = new AlertDialog.Builder(MainActivity.this);
				ventana2.setView(inflador2);
				ventana2.show();
				
			}


		});

		// Creacion del TabHost
		Resources res = getResources();

		TabHost tabs = (TabHost) findViewById(android.R.id.tabhost);
		tabs.setup();

		tabs.setup(this.getLocalActivityManager());

		Intent inicio;
		inicio = new Intent().setClass(this, Inicio.class);
		TabHost.TabSpec spec = tabs.newTabSpec("mitab1");
		spec.setContent(inicio);
		spec.setIndicator("", res.getDrawable(R.drawable.selector_tab_inicio));
		tabs.addTab(spec);

		Intent posicionamiento;
		posicionamiento = new Intent().setClass(this, Posicionamiento.class);
		spec = tabs.newTabSpec("mitab2");
		spec.setContent(posicionamiento);
		spec.setIndicator("",
				res.getDrawable(R.drawable.selector_tab_posicionamiento));
		tabs.addTab(spec);

		Intent alarma;
		alarma = new Intent().setClass(this, Alarma.class);
		spec = tabs.newTabSpec("mitab3");
		spec.setContent(alarma);
		spec.setIndicator("", res.getDrawable(R.drawable.selector_tab_alarma));
		tabs.addTab(spec);

		Intent actividad;
		actividad = new Intent().setClass(this, Actividad.class);
		spec = tabs.newTabSpec("mitab4");
		spec.setContent(actividad);
		spec.setIndicator("",
				res.getDrawable(R.drawable.selector_tab_actividad));
		tabs.addTab(spec);

		Intent palmares;
		palmares = new Intent().setClass(this, Palmares.class);
		spec = tabs.newTabSpec("mitab5");
		spec.setContent(palmares);
		spec.setIndicator("",
				getResources().getDrawable(R.drawable.selector_tab_palmares));
		tabs.addTab(spec);

		tabs.setCurrentTab(0);

	}
}
